import request from '/@/utils/request';

/**
 * 商品
 * @param params 要传的参数值
 * @returns 返回接口数据
 * 商品api接口集合
 */
export function useProductApi() {
	return {
		getProdList: (data) => {
			return request({
				url: '/product/admin/product/list',
				method: 'post',
				data,
			});
		},
		//查-详情
		getProdById: (id) => {
			return request({
				url: `/product/admin/product/detail/${id}`,
				method: 'get',
			});
		},
		//增
		addProd: (data) => {
			return request({
				url: '/product/admin/product/add',
				method: 'post',
				data,
			});
		},
		//改
		editProd: (data) => {
			return request({
				url: '/product/admin/product/update',
				method: 'post',
				data,
			});
		},
		updateCommission: (data) => {
			return request({
				url: '/product/sku-stock/admin/commission',
				method: 'post',
				data,
			});
		},
		//修改上架状态
		updatePublishStatus: (id) => {
			return request({
				url: `product/admin/product/publishStatus/${id}/${publishStatus}`,
				method: 'get',
			});
		},
		//批量修改上架状态
		mulUpdatePublishStatus: (data) => {
			return request({
				url: '/product/admin/product/publishStatus',
				method: 'post',
				data,
			});
		},
		//批量取消新品标识
		mulCancelNew: ({ idList, newStatus = 0 }) => {
			return request({
				url: '/product/admin/product/publishNewStatus',
				method: 'post',
				data: {
					idList,
					newStatus,
				},
			});
		},
		//修改商品排序
		updateSort: (data) => {
			return request({
				url: '/product/admin/product/updateSort',
				method: 'post',
				data,
			});
		},
		//获取商品列表with sku列表
		getProdListWithSkuList: (data) => {
			return request({
				url: '/product/admin/product/listForCoupon',
				method: 'post',
				data,
			});
		},
		//查-SKU列表
		getProdSkuList: (data) => {
			return request({
				url: '/product/sku-stock/admin/list',
				method: 'post',
				data,
			});
		},
		//批量上、下架sku商品
		mulUpdatePublishStatusSku: (data) => {
			return request({
				url: '/product/sku-stock/admin/publishStatus',
				method: 'post',
				data,
			});
		},
		//批量删除sku商品
		mulDelSku: (data) => {
			return request({
				url: '/product/sku-stock/admin/deleteStatus',
				method: 'post',
				data,
			});
		},
		//商品分类
		//查
		getCateList: (showStatus, cateType) => {
			return request({
				url: `/product/admin/product-category/list/${showStatus}/${cateType}`,
				method: 'get',
			});
		},
		//增
		addCate: (data) => {
			return request({
				url: '/product/admin/product-category/add',
				method: 'post',
				data,
			});
		},
		//改
		editCate: (data) => {
			return request({
				url: '/product/admin/product-category/update',
				method: 'post',
				data,
			});
		},
		//删
		// export const delCate = (id: number) => axios.post(`/product/admin/product-category/delete/${id}`);

		//商品参数
		//查
		getParamList: (data) => {
			return request({
				url: '/product/admin/product-attribute/list',
				method: 'post',
				data: {
					type: 1,
					...data,
				},
			});
		},
		//增
		addParam: (data) => {
			return request({
				url: '/product/admin/product-attribute/add',
				method: 'post',
				data: {
					type: 1,
					...data,
				},
			});
		},
		//删
		// export const delParam = (id: number) => axios.post(`/product/admin/product-attribute/delete/${id}`);
		//改
		editParam: (data) => {
			return request({
				url: '/product/admin/product-attribute/updateById',
				method: 'post',
				data: {
					type: 1,
					...data,
				},
			});
		},

		//更改状态
		updateParamStatus: ({ id, status }) => {
			return request({
				url: `/product/admin/product-attribute/update/${id}/${status}`,
				method: 'get',
			});
		},

		//商品维度
		//查
		getDimensionList: (data) => {
			return request({
				url: '/product/dimension/list',
				method: 'post',
				data,
			});
		},
		//增
		addDimension: (data) => {
			return request({
				url: '/product/dimension/admin/add',
				method: 'post',
				data,
			});
		},
		//改
		editDimension: (data) => {
			return request({
				url: '/product/dimension/admin/update',
				method: 'post',
				data,
			});
		},
		//商品规格
		//查
		getSpecificationList: (data) => {
			return request({
				url: '/product/admin/product-attribute/list',
				method: 'post',
				data: { type: 0, ...data },
			});
		},
		//增
		addSpecification: (data) => {
			return request({
				url: '/product/admin/product-attribute/add',
				method: 'post',
				data: { type: 0, ...data },
			});
		},
		//改
		editSpecification: (data) => {
			return request({
				url: '/product/admin/product-attribute/updateById',
				method: 'post',
				data: { type: 0, ...data },
			});
		},

		//商品支持
		//查
		getSupportList: (data) => {
			return request({
				url: '/product/admin/product-support/list',
				method: 'post',
				data,
			});
		},
		//增
		addSupport: (data) => {
			return request({
				url: '/product/admin/product-support/add',
				method: 'post',
				data,
			});
		},
		//改
		editSupport: (data) => {
			return request({
				url: '/product/admin/product-support/update',
				method: 'post',
				data,
			});
		},
		// 商品标签管理
		getGoodsTagList: (data) => {
			return request({
				url: '/product/product-tag/tag/list',
				method: 'post',
				data,
			});
		},
		updateGoodsTag: (data) => {
			return request({
				url: '/product/product-tag/admin/tag/update',
				method: 'post',
				data,
			});
		},
		addGoodsTag: (data) => {
			return request({
				url: '/product/product-tag/admin/tag/add',
				method: 'post',
				data,
			});
		},
		delGoodsTag: (data) => {
			return request({
				url: '/product/product-tag/admin/tag/del',
				method: 'post',
				data,
			});
		},
	};
}
